package com.lee.message.core.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;


@Data
@ConfigurationProperties(prefix = MqIdempotentProperties.PREFIX)
@Configuration
public class MqIdempotentProperties {

    public static final String PREFIX = "mq.idempotent";

    /**
     * 幂等启用
     */
    private boolean enabled = false;

    /**
     * mq消息组件
     */
    private MqServerRepository component = MqServerRepository.ROCKETMQ;

    /**
     * 数据存储
     */
    private MqIdempotentRepository repository = MqIdempotentRepository.REDIS;

    /**
     * redis可以分类存储数据，默认都在default
     */
    private String type = "default";

    /**
     * 存储幂等key
     */
    private String storeKey = "mq:unique:";

    /**
     * lockKey redis名字
     */
    private String lockKey = "mq:lock:";

    /**
     * 并发获取锁等待时间 TimeUnit.SECONDS
     */
    private Integer lockTime = 10;
    /**
     * 并发获取锁等待时间单位
     */
    private TimeUnit lockTimeUnit = TimeUnit.SECONDS;

    /**
     * 消费key存放时间默认3天
     */
    private Integer storeTime = 3;

    /**
     * 消费key存放时间单位
     */
    private TimeUnit storeTimeUnit = TimeUnit.DAYS;

}
